﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using FFIV.Lib.BusinessRules;
using System.Web.Security;
using FFIV.Lib.IView.Users;
using FFIV.Lib.Utilities;

namespace FFIV.Lib.Controlers.Admin
{
	public class RegisterUserController
	{
		private readonly IRegisterUser m_View;

		public RegisterUserController(IRegisterUser View)
		{
			m_View = View;
		}

		public void LoadPage()
		{
		}

		public void RegisterUser()
		{
			MembershipUser user = Membership.GetUser(m_View.Email);
			if (user == null)
			{
				UserRules.RegisterProcess(m_View.Email, m_View.Password, m_View.ShowName);
				HttpContext.Current.Response.Redirect(UrlUtility.Admin_ManageUser);
			}
			else
			{
				m_View.ErrorMessage = "用户名重复";
			}
		}
	}
}
